package com.example.rabbitmq.example.rabbitmq.hello;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.GetResponse;


public class HelloGetConsumer {

    public static void main(String[] args) throws  Exception {
        ConnectionFactory factory = new  ConnectionFactory();
        //%2f 是虚拟主机 /
        factory.setUri("amqp://admin:admin@192.168.1.3:5672/%2f");
        final Connection connection = factory.newConnection();
        final Channel channel = connection.createChannel();
        GetResponse rs = channel.basicGet("queue1", true);
        System.out.println(new String(rs.getBody()));
        channel.close();
        connection.close();
    }
}
